package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.*;
import com.ruoyi.hqfinance.domain.vo.HqTransferFeeSheetVo;
import com.ruoyi.hqfinance.mapper.*;
import com.ruoyi.hqfinance.service.HqTransferFeeSheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class HqTransferFeeSheetServiceImpl implements HqTransferFeeSheetService {
    @Autowired
    private HqTransferFeeSheetByNetworkMapper hqTransferFeeSheetByNetworkMapper;
    @Autowired
    private HqTransferFeeSheetByContractAreaMapper hqTransferFeeSheetByContractAreaMapper;
    @Autowired
    private HqTransferFeeSheetByTransferCentreMapper hqTransferFeeSheetByTransferCentreMapper;
    @Autowired
    private HqTransferFeeSheetByNetworkTransferCentreMapper hqTransferFeeSheetByNetworkTransferCentreMapper;
    @Autowired
    private HqTransferFeeSheetMapper hqTransferFeeSheetMapper;
    @Override
    public List<HqTransferFeeSheetByNetwork> collectTransferFeeByNetwork(HqTransferFeeSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqTransferFeeSheetByNetwork> transferFeeSheetByNetworks = hqTransferFeeSheetByNetworkMapper.collectTransferFeeByNetwork(vo);
        assert transferFeeSheetByNetworks != null;
        for (HqTransferFeeSheetByNetwork hqTransferFeeSheetByNetwork : transferFeeSheetByNetworks){
            hqTransferFeeSheetByNetwork.setTimePeriod(vo.getStartTime() + "至" + vo.getEndTime());
        }
        return transferFeeSheetByNetworks;
    }

    @Override
    public List<HqTransferFeeSheetByContractArea> collectByContractArea(HqTransferFeeSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqTransferFeeSheetByContractArea> transferFeeSheetByContractAreas = hqTransferFeeSheetByContractAreaMapper.collectByContractArea(vo);
        assert transferFeeSheetByContractAreas != null;
        for (HqTransferFeeSheetByContractArea hqTransferFeeSheetByContractArea : transferFeeSheetByContractAreas) {
            hqTransferFeeSheetByContractArea.setTimePeriod(vo.getStartTime() + "至" + vo.getEndTime());
        }
        return transferFeeSheetByContractAreas;
    }

    @Override
    public List<HqTransferFeeSheetByTransferCentre> collectByTransferCentre(HqTransferFeeSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqTransferFeeSheetByTransferCentre> transferFeeSheetByTransferCentres = hqTransferFeeSheetByTransferCentreMapper.collectByTransferCentre(vo);
        assert transferFeeSheetByTransferCentres != null;
        for (HqTransferFeeSheetByTransferCentre hqTransferFeeSheetByTransferCentre : transferFeeSheetByTransferCentres) {
            hqTransferFeeSheetByTransferCentre.setTimePeriod(vo.getStartTime() + "至" + vo.getEndTime());
        }
        return transferFeeSheetByTransferCentres;
    }

    @Override
    public List<HqTransferFeeSheetByNetworkTransferCentre> collectByNetworkTransferCentre(HqTransferFeeSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqTransferFeeSheetByNetworkTransferCentre> transferFeeSheetByNetworkTransferCentres = hqTransferFeeSheetByNetworkTransferCentreMapper.collectByNetworkTransferCentre(vo);
        assert transferFeeSheetByNetworkTransferCentres != null;
        for (HqTransferFeeSheetByNetworkTransferCentre hqTransferFeeSheetByNetworkTransferCentre : transferFeeSheetByNetworkTransferCentres) {
            hqTransferFeeSheetByNetworkTransferCentre.setTimePeriod(vo.getStartTime() + "至" + vo.getEndTime());
        }
        return transferFeeSheetByNetworkTransferCentres;
    }

    @Override
    public List<HqTransferFeeSheet> collect(HqTransferFeeSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        return hqTransferFeeSheetMapper.collect(vo);
    }
}
